package main

//编写一个函数，接收两个整数，然后返回它们的和、积与差。编写两个版本，一个是非命名返回值，一个是命名返回值。
//非命名返回值版本

import "fmt"

// SumProductDifferenceNonNamed 非命名版本 返回三个整数值,分别是和，积与差
func SumProductDifferenceNonNamed(a, b int) (int, int, int) {
	sum := a + b
	product := a * b
	difference := a - b
	return sum, product, difference
}

// SumProductDifferenceNamed 命名版本 返回三个命名的整数变量 sum product difference 这些变量在函数体内被赋值,return 语句可以省略具体返回值,因为已经通过命名返回值指定了
func SumProductDifferenceNamed(a, b int) (sum, product, difference int) {
	sum = a + b
	product = a * b
	difference = a - b
	return
}

func main() {
	a, b := 5, 3
	sum, product, difference := SumProductDifferenceNonNamed(a, b)
	fmt.Printf("sum=%d, product=%d, difference=%d\n", sum, product, difference)
	sum, product, difference = SumProductDifferenceNamed(a, b)
	fmt.Printf("sum=%d, product=%d, difference=%d\n", sum, product, difference)
}
